#pragma once
#include "files_needed.h"

//Added by Tyler Lawton on 9/12/2011
//If there is any questions regarding input and input accesories please email chickenman004@hotmail.com or find on Skype, thank you.
using namespace std;


class Windows_Input
{
private:
	deque<MSG> Messagequeue; // A deque made for storing important messages to be handled
public:
	inline static Windows_Input* Engine()	{ static Windows_Input i; return &i; }
	deque<MSG> getQueue() {return Messagequeue;} //return the queue of messages
	void MessageUsed(){Messagequeue.pop_front();} //This fuction will remove the first message in the queue
	bool ifMessage() //This is a quick and easy way to check if there is any messages in the queue
	{
		if(Messagequeue.empty())
			return false;
		return true;
	}
	MSG getMessage(){return Messagequeue[0];} //Retrieve the first message of the array
	int CheckMessage(MSG received_message) //Check for message importance.
	{
		///////////////////////
		// Every message going through will be checked to see if it is one used for the game
		// The switch statement checks the message portion (WM_KEYDOWN, WM_LBUTTONDOWN, Etc.)
		// If it is a type the program might need for the game, it will be pushed into the deque
		// After a copy has been pushed into the deque, return to the tranlate and dispatch with no changes
		// The same applies for a message not needed by the game, skip the switch and continue with translate and dispatch
		//
		// TLDR: This peeks at the current message, if it is meaningful it is copied to the deque, if not it continues on it's merry way.
		switch(received_message.message)
		{
		case WM_KEYDOWN:
			Messagequeue.push_back(received_message);
			break;
		case WM_LBUTTONDOWN:
			Messagequeue.push_back(received_message);
			break;
		default:
			break;
		}
		return 0;
	}
	
};
//Below is an example handler.
//The queue can be used anywhere as long as you use the getQueue() function
//This will give the current deque, so you can check for any input you need.
//The message part of each input is the type, (KeyDown, Mousebuttondown)
//The WParam and LParam are the individual details of each message
//if(!Messagequeue.empty())
//	{
//		MSG CurrMessage;
//		CurrMessage = Messagequeue[0];
//		//UINT uMsg = CurrMessage->message;
//		switch(CurrMessage.message)
//		{
//		case (WM_KEYDOWN):
//			{
//				switch(CurrMessage.wParam)
//				{
//				case VK_F:
//					{
//						break;
//					}
//				case VK_E:
//					{
//						break;
//					}
//				}
//			}
//		case (WM_LBUTTONDOWN):
//			{
//				int x = CurrMessage.pt.x;
//				int y = CurrMessage.pt.y;
//			}
//		default:
//			int a = 0;
//			break;
//		}
//		Messagequeue.pop_front();
//	}